package com.eig.stat.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.eig.common.entity.system.TbMember;
import com.eig.stat.dao.TbMemberDao;
import com.eig.stat.service.TbMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 会员表(TbMember)表服务实现类
 *
 * @author makejava
 * @since 2022-12-22 23:15:20
 */
@Service("tbMemberService")
public class TbMemberServiceImpl implements TbMemberService {
    @Resource
    private TbMemberDao tbMemberDao;

    @Override
    public List<Map> queryMemberTypeBang() {
        int a=0;
        int b=0;
        QueryWrapper<TbMember> wrapper = new QueryWrapper<>();
        List<TbMember> tbMembers = tbMemberDao.selectList(wrapper);
        for (TbMember tbMember : tbMembers) {
            if(tbMember.getIsType()==1){
                a++;
            }else {
                b++;
            }
        }
        Map<String, Object> map = new HashMap<>();
        map.put("name","会员");
        map.put("value",a);
        Map<String, Object> map1 = new HashMap<>();
        map1.put("name","用户");
        map1.put("value",b);
        List<Map> maps = new ArrayList<>();
        maps.add(map);
        maps.add(map1);
        return maps;

    }
}
